<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2017/7/10/010
  Time: 12:47
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>定位2（点击右上角新建营业厅按钮定位）</title>
    <script src="../js/jquery-3.1.1.min.js"></script>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=1.4"></script>
    <script type="text/javascript" src="http://api.map.baidu.com/library/MarkerTool/1.2/src/MarkerTool_min.js"></script>
    <script src="../js/newHall.js"></script>
</head>
<body>
<button id="new-hall-btn" class="btn btn-sm btn-primary "><i class="fa fa-map-marker"></i>新营业厅</button>
<button id="cancle-new-hall-btn" class="btn btn-sm btn-default ">取消添加</button>
<div class="row">
    <div class="col-lg-8">
        <div id="bmap_geocoding" style="height: 600px;">
        </div>
    </div>
</div>
</body>
<script type="text/javascript">
    var map = new BMap.Map("bmap_geocoding");          // 创建地图实例
    var point = new BMap.Point(112.460752,34.624123);
    map.centerAndZoom(point, 15);                 // 初始化地图，设置中心点坐标和地图级别
    //允许鼠标缩放
    map.enableScrollWheelZoom();
    //地图插件设置
    var controlOpt = {type: BMAP_NAVIGATION_CONTROL_SMALL};
    //向地图添加平移缩放插件
    map.addControl(new BMap.NavigationControl(controlOpt));
    //默认城市为洛阳
    map.setCurrentCity('洛阳');
    //本地搜索
    var local = new BMap.LocalSearch(map, {
        renderOptions:{map: map}
    });

    //添加标注
    var mkrTool = new BMapLib.MarkerTool(map, {autoClose: true, followText: "标注新营业厅"});
    $(function () {
        /**地图标记事件*/
        mkrTool.addEventListener("markend", function(evt){
            curMkr = evt.marker;
            curMkr.openInfoWindow(infoWin);
            getAddr(curMkr.getPosition());
            //    staffNameTypeAhead('${baseURL}/staff/searchNegozianteName');
        });
        try {
            newHallBtn();
        }catch (error){
            console.log(error);
        }

        $("#cancle-new-hall-btn").hide();
        /**新增营业厅视图*/
        $("#new-hall-btn").click(function () {
            $(this).hide();
            $("#cancle-new-hall-btn").show();
            mkrTool.open();
        });

        /**取消按钮事件*/
        $("#cancle-new-hall-btn").click(function () {
            $(this).hide();
            //关闭添加标注方法
            mkrTool.close();
            if (curMkr){
                //移除刚刚添加的标记
                map.removeOverlay(curMkr);
            }
            $("#new-hall-btn").show();
        });
    });
</script>
</html>
